package com.qgs.rabbitmqapi.consumer;

import com.rabbitmq.client.*;

import java.io.IOException;

/**
 * @Author: 蔡翔
 * @Date: 2019/7/19 13:27
 * @Version 1.0
 */
public class Producer {
    public static void main(String[] args) throws Exception {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("192.168.0.229");
        connectionFactory.setVirtualHost("/");
        connectionFactory.setPort(5672);

        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();

        String exchange = "test_consumer_exchange";
        String routingKey = "consumer.save";

        String msg = "hello rabbitmq Consumer message";

        for(int i=0;i<5;i++){
            channel.basicPublish(exchange,routingKey,true,null,msg.getBytes());
        }


    }
}
